﻿using System.Runtime.InteropServices;
using System;
using PCLLearning.Framework;
using PointCloudSharp;

namespace PCLCSharpLearning
{
    internal class Program
    {
        static void Main(string[] args)
        {
            VoxelGridDownsampling();

            //Console.ReadKey();
        }

        static void VoxelGridDownsampling()
        {
            var filePath=Win32API.OpenFile("All files\0*.*\0Image files\0*.jpg;*.png\0");
            //输入的点云对象
            PointCloudXYZ cloud = new PointCloudXYZ();
            //滤波后的点云对象
            PointCloudXYZ cloud_res = new PointCloudXYZ();

            //加载ply文件，并将点云对象存储到cloud中的PointCloudPointer指针中
            PclCSharp.Io.loadPcdFile(filePath, cloud.PointCloudXYZPointer);
            
            PclCSharp.Filter.voxelDownSample(cloud.PointCloudXYZPointer, 0.08, cloud_res.PointCloudXYZPointer);

            //另存为pcd
            //第三个参数为0,代表以assii格式存储，参数为1，代表以二进制形式存储。二进制形式读取速度更快
            PclCSharp.Io.savePcdFile("D:\\项目\\点云质量打分\\源文件\\PclCSharp\\PclCSharp-master\\source\\pcdFiles\\filter result\\"+Path.GetFileName(filePath), cloud_res.PointCloudXYZPointer, 0);
        }
    }
}
